package library.Function
{
	import flash.utils.Dictionary;
	
	public class Dict
	{
		private var _dictionary:Dictionary;
		
		public function Dict(weakKeys:Boolean=false)
		{
			this._dictionary = new Dictionary(weakKeys);
		}
		
		public function has_key(key:* = null):Boolean
		{
			return this._dictionary.hasOwnProperty(key);
		}
		
		public function get length():int
		{
			var len:int = 0;
			for(var i:* in this._dictionary)
			{
				if(this._dictionary[i] != null)
					len++;
			}
			return len;
		}
		
		public function clear():void
		{
			for(var i:* in this._dictionary)
			{
				this._dictionary[i] = null;
				delete this._dictionary[i];
			}
		}
		
		public function remove(key:*):void
		{
			if(this._dictionary.hasOwnProperty(key))
			{
				this._dictionary[key] = null;
				delete this._dictionary[key];
			}
		}
		
		public function pop(key:*):Object
		{
			var obj:Object = null;
			if(this._dictionary.hasOwnProperty(key))
			{
				obj = this._dictionary[key];
				this._dictionary[key] = null;
				delete this._dictionary[key];
			}
			return obj;
		}
		
		public function get dictionary():Dictionary
		{
			return this._dictionary;
		}
		
		public function getValue(key:*):Object
		{
			return this._dictionary[key];
		}
		
	}
}